<template>
	<view id="WorkOrderDetails">
		<view class="public_item">
			<text>工单编号</text>
			<text>{{'No.'+all._id?.slice(-6)}}</text>
		</view>
		<view class="public_item">
			<text>报修类型</text>
			<text>{{all?.types}}</text>
		</view>
		<view class="public_item">
			<text>报修位置</text>
			<text>{{all?.address}}</text>
		</view>
		<view class="public_item">
			<text>联系人</text>
			<text>{{all?.repair_applicant}}</text>
		</view>
		<view class="public_item">
			<text>联系电话</text>
			<text>{{all?.phone}}</text>
		</view>
		<view class="public_item">
			<text>维修部门</text>
			<text>{{all.department?.dname}}</text>
		</view>
		<view class="public_item">
			<text>报修时间</text>
			<text>{{all?.create_time}}</text>
		</view>
		<view class="public_item public_describe">
			<text>故障描述</text>
			<text>{{all?.describe}}</text>
		</view>
		<view class="public_item public_photo">
			<text>故障照片</text>
			<!-- <text>{{all}}</text> -->
			<view class="images">
				<image :src="items" v-for="(items,indexs) in all?.old_imgs"></image>
			</view>
		</view>
		<view class="public_item" @click="goto" v-show="showData?.name">
			<text>{{showData?.name}}</text>
			<uni-icons type="right"></uni-icons>
		</view>
		<button v-show="showData?.name"
			@click="showData.status==1? report():pinjia()">{{showData.status==1?'报完成':'待评价'}}</button>
		<button v-show="!showData?.name" @click="handlerJie(all?._id)">接单</button>
	</view>
</template>

<script setup>
	import {
		request
	} from '@/unit/request.js'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		nextTick,
		ref
	} from "vue";
	let showData = ref({})
	let all = ref({})
	const report = () => {
		uni.navigateTo({
			url: "/pages/work-order-management/work-order-report-completed/work-order-report-completed?_id=" +
				all.value?._id
		})
	}
	const pinjia=()=>{
		console.log('aaaaaaa');
		uni.navigateTo({
			url:"/pages/work-order-management/work-order-evaluation/work-order-evaluation?_id="+all.value?._id
		})
	}
	onLoad((option) => {
		console.log(option);
		showData.value = option
		console.log(option, 123);
		request({
			url: "http://42.192.15.126:3000/yan/work_dan?id=" + option._id,
			method: 'GET'
		}).then(item => {
			console.log(item);
			all.value = item.data
		})
	})
	let goto = () => {
		uni.navigateTo({
			url: showData.value.redirect + '?num=2'
		})
	}
	const handlerJie = (id) => {
		request({
			url: "http://42.192.15.126:3000/yan/work_update?id=" + all.value?._id + '&num=2',
			method: 'PUT'
		}).then(item => {
			uni.navigateTo({
				url: "/pages/work-order-management/work-order-query/work-order-query"
			})
		})
	}
</script>

<style lang="scss">
	.images {
		display: flex;
		justify-content: flex-start;
		flex-wrap: wrap;

		image {
			width: 150rpx;
			height: 150rpx;
		}
	}

	#WorkOrderDetails {
		height: calc(100vh - 44px);
		background-color: #f4f6f9;

		.public_item {
			padding: 30rpx 40rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: white;
			border-bottom: 1rpx solid #e2e4e7;
		}

		.public_describe {
			display: flex;
			flex-direction: column;
			align-items: flex-start;
		}

		.public_photo {
			flex-direction: column;
			align-items: flex-start;
		}

		button {
			width: 30%;
			color: white;
			background-color: #3366ff;
			margin-top: 60rpx;
		}
	}
</style>
